﻿<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPageContent.master" AutoEventWireup="false" CodeFile="PurchaseRequestDtl.aspx.vb" Inherits="Purchase_PurchaseRequestDtl" %>

<%@ Register Src="~/UserControls/DDL.ascx" TagName="DoubleFilteredDropDownList" TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/OneFilteredDropDownList.ascx" TagName="OneFilteredDropDownList"
    TagPrefix="uc2" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">


    <link href="~/Design/EasyAccounting/Buttons.css" rel="stylesheet" type="text/css" />
    
    <script type="text/javascript">

        function Confirm(sender, args) {

            var DeleteButton = $find("<%=rbtnDelete.ClientID %>");

            if (confirm('Are You Sure you Want to Delete the Form ?')) {
                DeleteButton.set_autoPostBack(true);
            }
            else {
                DeleteButton.set_autoPostBack(false);
                //args.set_cancel(true);
                //sender.set_cancel(true);
            }
        }
    
    </script>


</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeaderPlaceHolder" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">







    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgPurchaseRequestDtl">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgPurchaseRequestDtl" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnSave">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Office2010Blue"
        Transparency="20">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    </telerik:RadWindowManager>



    <br />
    <br />
    <table style="table-layout: fixed;">
        <tr>
            <td>
                <asp:Label ID="lblManrdpPurReqDate" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                <asp:Label ID="lblPurReqDate" runat="server" meta:ResourceKey="lblPurReqDate"></asp:Label>
            </td>
            <td>
                <telerik:RadDatePicker runat="server" ID="rdpPurReqDate" Culture="English (United States)"
                    ShowPopupOnFocus="true" ValidationGroup="valPurchaseRequestHdr">
                    <DateInput ID="DateInput1" DateFormat="dd/MM/yyyy" runat="server">
                    </DateInput></telerik:RadDatePicker>
                <asp:RequiredFieldValidator ID="rfvrdpPurReqDate" runat="server" ControlToValidate="rdpPurReqDate"
                    ErrorMessage="<%$ Resources:Controls, ErrorMessage %>" ValidationGroup="valPurchaseRequestHdr"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lblManrtbPurReqNo" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                <asp:Label ID="lblPurReqNo" runat="server" meta:ResourceKey="lblPurReqNo"></asp:Label>
            </td>
            <td>
                <telerik:RadTextBox ID="rtbPurReqNo" runat="server" Skin="MetroTouch" ValidationGroup="valPurchaseRequestHdr">
                </telerik:RadTextBox>
                <asp:RequiredFieldValidator ID="rfvrtbPurReqNo" runat="server" ControlToValidate="rtbPurReqNo"
                    ErrorMessage="<%$ Resources:Controls, ErrorMessage %>" ValidationGroup="valPurchaseRequestHdr"></asp:RequiredFieldValidator>
            </td>
            <td>
                <asp:Label ID="lblManPurReqType" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                <asp:Label ID="lblPurReqType" runat="server" meta:ResourceKey="lblPurReqType"></asp:Label>
            </td>
            <td>
                <uc2:OneFilteredDropDownList ID="rcbPurReqType" runat="server" DataSourceId="odsPurReqType"
                    DataValueField="MINOR" IsRequired="true" DataTextField="<%$ Resources:SystemResource, Lookup %>"
                    DefaultChoosedItem="ChooseOne" ValidationGroup="valPurchaseRequestHdr" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lblCostCenter" runat="server" meta:ResourceKey="lblCostCenter"></asp:Label>
            </td>
            <td>
                <uc2:OneFilteredDropDownList ID="rcbCostCenter" runat="server" DataSourceId="odsCostCenter"
                    DataValueField="MINOR" IsRequired="false" DataTextField="<%$ Resources:SystemResource, Lookup %>"
                    DefaultChoosedItem="ChooseOne" ValidationGroup="valPurchaseRequestHdr" />
            </td>
            <td>
                <asp:Label ID="lblMainCostCenter" runat="server" meta:ResourceKey="lblMainCostCenter"></asp:Label>
            </td>
            <td>
                <uc2:OneFilteredDropDownList ID="rcbMainCostCenter" runat="server" DataSourceId="odsMainCostCenter"
                    DataValueField="MINOR" IsRequired="false" DataTextField="<%$ Resources:SystemResource, Lookup %>"
                    DefaultChoosedItem="ChooseOne" ValidationGroup="valPurchaseRequestHdr" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lblRemarks" runat="server" meta:ResourceKey="lblMainRemarks"></asp:Label>
            </td>
            <td>
                <telerik:RadTextBox ID="rtbRemarks" runat="server" SkinID="Remarks">
                </telerik:RadTextBox>
            </td>
            <td>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td colspan="4">
                <!------------------------------------------------ Details ---------------------------------------------------->
                <telerik:RadGrid ID="rgPurchaseRequestDtl" runat="server" GridLines="None" DataSourceID="sdsPurchaseRequestDtl"
                    AllowAutomaticDeletes="True" AllowAutomaticInserts="True" ShowFooter="True" AllowAutomaticUpdates="True"
                    Skin="MetroTouch" AllowPaging="True" AutoGenerateColumns="False" GroupPanel-Text="<%$ Resources:MainGrid ,GroupPanelText %>"
                    CellSpacing="0">
                    <MasterTableView Width="100%" Caption="<%$ Resources:MainGrid , LinesCaption %>"
                        CommandItemDisplay="TopAndBottom" DataKeyNames="ID" TableLayout="Fixed" HorizontalAlign="NotSet"
                        DataSourceID="sdsPurchaseRequestDtl" NoMasterRecordsText="<%$ Resources:MainGrid , NoMasterRecordsText %>">
                        <CommandItemTemplate>
                            <table>
                                <tr>
                                    <td>
                                        <asp:ImageButton ID="ibtnInitInsert" CommandName="InitInsert" runat="server" ImageUrl="~/Design/images/Grid/AddRecord.gif" />
                                        <asp:LinkButton ID="lbtnInitInsert" runat="server" Font-Size="14px" Text="<%$ Resources:MainGrid , AddNew %>"
                                            CommandName="InitInsert" Visible="true" />&nbsp;&nbsp;&nbsp;&nbsp;
                                        <asp:ImageButton ID="ibtnEditSelected" CommandName="EditSelected" runat="server"
                                            ImageUrl="~/Design/images/Grid/Edit.gif" />
                                        <asp:LinkButton ID="lbtnEditSelected" runat="server" Font-Size="14px" Text="<%$ Resources:MainGrid , EditSelected %>"
                                            CommandName="EditSelected" Visible="true" />&nbsp;&nbsp;&nbsp;&nbsp;
                                        <asp:ImageButton ID="ibtnDeleteSelected" CommandName="DeleteSelected" runat="server"
                                            ImageUrl="~/Design/images/Grid/Delete.gif" />
                                        <asp:LinkButton ID="lbtnDeleteSelected" Font-Size="14px" OnClientClick="<%$ Resources:MainGrid , OnClientClickDelete %>"
                                            runat="server" Text="<%$ Resources:MainGrid , DeleteSelected %>" CommandName="DeleteSelected" />&nbsp;&nbsp;&nbsp;&nbsp;
                                        <asp:ImageButton ID="ibtnRebindGrid" CommandName="RebindGrid" runat="server" ImageUrl="~/Design/images/Grid/Refresh.gif" />
                                        <asp:LinkButton ID="lbtnRebindGrid" Font-Size="14px" runat="server" Text="<%$ Resources:MainGrid , Refresh %>"
                                            CommandName="RebindGrid" />
                                    </td>
                                </tr>
                            </table>
                        </CommandItemTemplate>
                        <Columns>
                            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton">
                                <HeaderStyle Width="30px" />
                                <ItemStyle Width="30px" />
                            </telerik:GridEditCommandColumn>

                            <telerik:GridBoundColumn DataField="ID" SortExpression="ID"
                                UniqueName="ID" Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="PurReqID" SortExpression="PurReqID"
                                UniqueName="PurReqID" Visible="false">
                                <HeaderStyle Width="50px" />
                                <ItemStyle Width="50px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ProgramNo" meta:ResourceKey="gbcProgramNo"
                                SortExpression="ProgramNo" UniqueName="ProgramNo">
                                <HeaderStyle Width="100px" />
                                <ItemStyle Width="100px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ProjectNo" meta:ResourceKey="gbcProjectNo" SortExpression="ProjectNo"
                                UniqueName="ProjectNo">
                                <HeaderStyle Width="100px" />
                                <ItemStyle Width="100px" />
                            </telerik:GridBoundColumn>

                            <telerik:GridDropDownColumn DataField="ItemNo" DataSourceID="odsItem" meta:ResourceKey="gbcItem"
                                ListTextField="<%$ Resources:SystemResource, Item %>" ListValueField="ItemID"
                                UniqueName="ItemNo" EnableEmptyListItem="True">
                                <HeaderStyle Width="100px" />
                                <ItemStyle Width="100px" />
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="ItemNo"
                                SortExpression="ItemNo" UniqueName="Item" Visible="false"/>

                            <telerik:GridDropDownColumn DataField="UnitNo" DataSourceID="odsUnit" meta:ResourceKey="gbcUnit"
                                ListTextField="<%$ Resources:SystemResource, Unit %>" ListValueField="UnitID"
                                UniqueName="UnitNo" EnableEmptyListItem="True">
                                <HeaderStyle Width="100px" />
                                <ItemStyle Width="100px" />
                            </telerik:GridDropDownColumn>
                            <telerik:GridBoundColumn DataField="UnitNo"
                                SortExpression="UnitNo" UniqueName="Unit" Visible="false"/>

                            <telerik:GridBoundColumn DataField="UnitPrice" meta:ResourceKey="gbcUnitPrice"
                                SortExpression="UnitPrice" UniqueName="UnitPrice" Visible="true" DataFormatString="{0:###,###.##}">
                                <HeaderStyle Width="75px" />
                                <ItemStyle Width="75px" />
                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn DataField="Qty" meta:ResourceKey="gbcQty"
                                SortExpression="Qty" UniqueName="Qty" Visible="true">
                                <HeaderStyle Width="50px" />
                                <ItemStyle Width="50px" />
                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn DataField="PurchaseReason" meta:ResourceKey="gbcPurchaseReason" 
                                SortExpression="PurchaseReason" UniqueName="PurchaseReason" Visible="true">
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px"/>
                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn DataField="Remarks" meta:ResourceKey="gbcRemarks" 
                                SortExpression="Remarks" UniqueName="Remarks" Visible="true">
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="150px" />
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="150px"/>
                            </telerik:GridBoundColumn>

                            <telerik:GridButtonColumn UniqueName="DeleteColumn" ConfirmText="<%$ Resources:MainGrid , ConfirmDelete %>"
                                ConfirmTitle="Confirm" ButtonType="ImageButton" CommandName="Delete">
                                <HeaderStyle Width="30px" />
                                <ItemStyle Width="30px" />
                            </telerik:GridButtonColumn>
                        </Columns>
                        <EditFormSettings ColumnNumber="2" EditFormType="Template" CaptionDataField="ID"
                            CaptionFormatString="Edit properties of {0}" InsertCaption="New Line">
                            <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                            <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                            <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                                Width="100%" />
                            <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                            <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                            <EditColumn ButtonType="ImageButton" InsertText="Insert User" UpdateText="Update record"
                                UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                            </EditColumn>
                            <FormTableButtonRowStyle CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                            <FormTemplate>
                                <table id="Table2" cellspacing="2" cellpadding="1" border="0" rules="none">
                                    <tr>
                                        <td>
                                            <asp:Label ID="lblNewLine" Font-Bold="true" Font-Italic="true" runat="server" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "New Line", "Update Line") %>'
                                                SkinID="KeyLabel"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="lblProgramNo" SkinID="KeyLabel" runat="server" meta:ResourceKey="lblProgramNo"></asp:Label>
                                        </td>
                                        <td>
                                            <telerik:RadTextBox ID="rtbProgramNo" runat="server" ValidationGroup="valPurchaseRequestDtl"
                                                Text='<%# Bind("ProgramNo") %>'>
                                            </telerik:RadTextBox>
                                        </td>
                                        <td>
                                            <asp:Label ID="lblProjectNo" runat="server" meta:ResourceKey="lblProjectNo" SkinID="KeyLabel"></asp:Label>
                                        </td>
                                        <td>
                                            <telerik:RadTextBox ID="rtbProjectNo" runat="server" Text='<%# Bind("ProjectNo") %>' ValidationGroup="valPurchaseRequestDtl">
                                            </telerik:RadTextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="lblManItem" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                                            <asp:Label ID="lblItem" runat="server" meta:ResourceKey="lblItem" SkinID="KeyLabel"></asp:Label>
                                        </td>
                                        <td>
                                            <uc1:DoubleFilteredDropDownList ID="WUCItem" IsRequired="true" runat="server" DataSourceId="odsItem" OnSelectedIndexChanged="WUCItem_SelectedIndexChanged"
                                                DataTextField="<%$ Resources:SystemResource, Item %>" DataValueField="ItemID" AutoPostBack="true"
                                                SelectedValue='<%# Bind("ItemNo") %>' DefaultChoosedItem="ChooseOne" ValidationGroup="valPurchaseRequestDtl" />
                                        </td>
                                        <td></td>
                                        </tr>
                                        <tr>
                                        
                                        <td>
                                            <asp:Label ID="lblManUnit" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                                            <asp:Label ID="lblUnit" SkinID="KeyLabel" runat="server" meta:ResourceKey="lblUnit"></asp:Label>                                            
                                        </td>
                                        <td>
                                            <uc1:DoubleFilteredDropDownList ID="WUCUnit" IsRequired="true" runat="server" DataSourceId="odsDynamicUnit"
                                                DataTextField="<%$ Resources:SystemResource, Unit %>" DataValueField="UnitID"
                                                SelectedValue='<%# Bind("UnitNo") %>' DefaultChoosedItem="ChooseOne" ValidationGroup="valPurchaseRequestDtl" />
                                        </td>
                                        </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="lblManrntbUnitPrice" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                                            <asp:Label ID="lblrntbUnitPrice" runat="server" meta:ResourceKey="lblUnitPrice" SkinID="KeyLabel"></asp:Label>
                                        </td>
                                        <td>
                                            <telerik:RadNumericTextBox ID="rntbUnitPrice" runat="server" ValidationGroup="valPurchaseRequestDtl"
                                                IncrementSettings-InterceptArrowKeys="true" IncrementSettings-InterceptMouseWheel="true"
                                                Text='<%# Bind("UnitPrice") %>'>
                                                <NumberFormat DecimalDigits="2" GroupSizes="4" />
                                            </telerik:RadNumericTextBox>
                                            <asp:RequiredFieldValidator ID="rfvrntbUnitPrice" runat="server" ControlToValidate="rntbUnitPrice"
                                            ErrorMessage="<%$ Resources:Controls, ErrorMessage %>" ValidationGroup="valPurchaseRequestDtl"></asp:RequiredFieldValidator>
                                        </td>

                                        <td>
                                            <asp:Label ID="lblManQty" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>"></asp:Label>
                                            <asp:Label ID="lblQty" runat="server" meta:ResourceKey="lblQty" SkinID="KeyLabel"></asp:Label>
                                        </td>
                                        <td>
                                            <telerik:RadNumericTextBox ID="rntbQty" runat="server" ValidationGroup="valPurchaseRequestDtl"
                                                IncrementSettings-InterceptArrowKeys="true" IncrementSettings-InterceptMouseWheel="true"
                                                Text='<%# Bind("Qty") %>'>
                                            </telerik:RadNumericTextBox>
                                            <asp:RequiredFieldValidator ID="rfvrntbQty" runat="server" ControlToValidate="rntbQty"
                                            ErrorMessage="<%$ Resources:Controls, ErrorMessage %>" ValidationGroup="valPurchaseRequestDtl"></asp:RequiredFieldValidator>
                                        </td>

                                     </tr>
                                     <tr>
                                        <td>
                                            <asp:Label ID="lblPurchaseReason" runat="server" meta:ResourceKey="lblPurchaseReason" SkinID="KeyLabel"></asp:Label>
                                        </td>
                                        <td >
                                            <telerik:RadTextBox ID="rtbPurchaseReason" SkinID="Remarks" runat="server" Text='<%# Bind("PurchaseReason") %>' ValidationGroup="valPurchaseRequestDtl">
                                            </telerik:RadTextBox>
                                        </td>

                                        <td>
                                            <asp:Label ID="lblRemarks" runat="server" meta:ResourceKey="lblRemarks" SkinID="KeyLabel"></asp:Label>
                                        </td>
                                        <td >
                                            <telerik:RadTextBox ID="rtbRemarks" SkinID="Remarks" runat="server" Text='<%# Bind("Remarks") %>' ValidationGroup="valPurchaseRequestDtl">
                                            </telerik:RadTextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="6">
                                            <div style="margin-top: 10px">
                                                <telerik:RadButton ID="btnInsert" meta:ResourceKey="btnInsert" Visible='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "True", "False") %>'
                                                    runat="server" CommandName="PerformInsert" Icon-PrimaryIconCssClass="rbOk" CausesValidation="true" ValidationGroup="valPurchaseRequestDtl">
                                                </telerik:RadButton>
                                                <telerik:RadButton ID="btnUpdate" meta:ResourceKey="btnUpdate" Visible='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "False", "True") %>'
                                                    runat="server" CommandName="Update" CausesValidation="true" ValidationGroup="valPurchaseRequestDtl"
                                                    Icon-PrimaryIconCssClass="rbOk">
                                                </telerik:RadButton>
                                                &nbsp;
                                                <telerik:RadButton ID="btnCancel" meta:ResourceKey="btnCancel" runat="server" CausesValidation="False"
                                                    CommandName="Cancel" Icon-PrimaryIconCssClass="rbCancel" >
                                                </telerik:RadButton>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </FormTemplate>
                        </EditFormSettings>
                        <CommandItemSettings ExportToPdfText="Export to PDF" />
                        <RowIndicatorColumn>
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn>
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                            Font-Underline="False" HorizontalAlign="Center" Wrap="True" />
                    </MasterTableView>
                    <ValidationSettings CommandsToValidate="PerformInsert,Update" ValidationGroup="valEditMode" />
                    <ClientSettings AllowDragToGroup="False">
                        <Scrolling AllowScroll="false" ScrollHeight="400px" />
                        <Selecting AllowRowSelect="True" />
                    </ClientSettings>
                    <FilterMenu EnableTheming="True">
                        <CollapseAnimation Duration="200" Type="OutQuint" />
                    </FilterMenu>
                    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                </telerik:RadGrid>

                <asp:HiddenField ID="hdnPurReqID" runat="server" />

    <br />
    <br />
    
    <telerik:RadButton ID="btnSave" runat="server" Text="Save" CausesValidation="true"  meta:ResourceKey="btnSave" ValidationGroup="valPurchaseRequestHdr" >
                        </telerik:RadButton>
    &nbsp;
    <telerik:RadButton ID="rbtnDelete" runat="server" Text="Delete" OnClientClicking="Confirm" meta:ResourceKey="btnDelete" CausesValidation="false"  >
                        </telerik:RadButton>
    &nbsp;
    <telerik:RadButton ID="btnCancel" runat="server" Text="Cancel"  meta:ResourceKey="btnCancel" CausesValidation="false"  >
                        </telerik:RadButton>

    <sds:SessionDataSource ID="sdsPurchaseRequestDtl" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
        SelectCommand="select PurchaseRequestDtl.[ID]
	  ,PurchaseRequestDtl.[PurReqID]
	  ,PurchaseRequestDtl.[ProgramNo]
      ,PurchaseRequestDtl.[ProjectNo]
      ,PurchaseRequestDtl.[ItemNo]
      ,PurchaseRequestDtl.[UnitNo]
      ,PurchaseRequestDtl.[UnitPrice]
      ,PurchaseRequestDtl.[Qty]
      ,PurchaseRequestDtl.[PurchaseReason]
      ,PurchaseRequestDtl.[Remarks] from PurchaseRequestDtl WHERE  PurReqID = @PurReqID"
        DeleteCommand="DELETE FROM [PurchaseRequestDtl] WHERE [ID] = ?" 
        InsertCommand="insert into PurchaseRequestDtl
	    ( PurReqID , ProgramNo , ProjectNo , ItemNo , UnitNo , UnitPrice ,  Qty , PurchaseReason , Remarks )
	    Values ( @PurReqID , ?, ? ,?, ?, ?, ?, ?, ?)"
        UpdateCommand="Update PurchaseRequestDtl
	    set  PurReqID = @PurReqID , [ProgramNo] = @ProgramNo , ProjectNo = @ProjectNo , ItemNo = @ItemNo , UnitNo = @UnitNo , UnitPrice = @UnitPrice , Qty = @Qty , PurchaseReason = @PurchaseReason , Remarks = @Remarks WHERE PurReqID = ? , [ProgramNo] = ? , ProjectNo = ? , ItemNo = ? , UnitNo = ? , UnitPrice = ? , Qty = ? , PurchaseReason = ? , Remarks = ?"
        PrimaryKeyFields="ID" OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues"
        ClearSessionOnInitialLoad="True" SessionKey="System.Web.UI.Page_sdsPurchaseRequest">
        <SelectParameters>
            <asp:ControlParameter ControlID="hdnPurReqID" Name="PurReqID" PropertyName="Value"
                Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:ControlParameter ControlID="hdnPurReqID" Name="PurReqID" PropertyName="Value"
                Type="String" />
            <asp:Parameter Name="ProgramNo" />
            <asp:Parameter Name="ProjectNo" />
            <asp:Parameter Name="ItemNo" />
            <asp:Parameter Name="UnitNo" />
            <asp:Parameter Name="UnitPrice" />
            <asp:Parameter Name="Qty" />
            <asp:Parameter Name="PurchaseReason" />
            <asp:Parameter Name="Remarks" />
        </UpdateParameters>
        <InsertParameters>
            <asp:ControlParameter ControlID="hdnPurReqID" Name="PurReqID" PropertyName="Value"
                Type="String" />
        </InsertParameters>
    </sds:SessionDataSource>

    <asp:ObjectDataSource ID="odsItem" runat="server" SelectMethod="QueryDatabase"
        TypeName="DBItemSP">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvItem" Name="Operation" Type="String" />
            <asp:Parameter Name="ItemID" Type="String" />
            <asp:Parameter Name="ItemNameAr" Type="String" />
            <asp:Parameter Name="ItemNameEn" Type="String" />
            <asp:Parameter Name="ItemDesc" Type="String" />
            <asp:Parameter Name="Highlevel" Type="String" />
            <asp:Parameter Name="LowLevel" Type="String" />
            <asp:Parameter Name="ItemCatNo" Type="String" />
            <asp:Parameter Name="ItemStatus" Type="String" />
            <asp:Parameter Name="IsExpiryDate" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="odsUnit" runat="server" SelectMethod="QueryDatabase"
        TypeName="DBUnitSP">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvUnit" Name="Operation" Type="String" />
            <asp:Parameter Name="UnitID" Type="String" />
            <asp:Parameter Name="UnitNameAr" Type="String" />
            <asp:Parameter Name="UnitNameEn" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="odsDynamicUnit" runat="server" SelectMethod="QueryDatabase"
        TypeName="DBUnitSP">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvUnitByItemID" Name="Operation" Type="String" />
            <asp:Parameter Name="UnitID" Type="String" />
            <asp:Parameter Name="UnitNameAr" Type="String" />
            <asp:Parameter Name="UnitNameEn" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="odsCostCenter" runat="server" SelectMethod="QueryDatabase"
        TypeName="DBlookup_tableSP">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvCostCenter" Name="Operation" Type="String" />
            <asp:Parameter Name="MAJOR" Type="String" />
            <asp:Parameter Name="MINOR" Type="String" />
            <asp:Parameter Name="DescriptionAr" Type="String" />
            <asp:Parameter Name="DescriptionEn" Type="String" />
            <asp:Parameter Name="OrderID" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="odsMainCostCenter" runat="server" SelectMethod="QueryDatabase"
        TypeName="DBlookup_tableSP">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvMainCostCenter" Name="Operation" Type="String" />
            <asp:Parameter Name="MAJOR" Type="String" />
            <asp:Parameter Name="MINOR" Type="String" />
            <asp:Parameter Name="DescriptionAr" Type="String" />
            <asp:Parameter Name="DescriptionEn" Type="String" />
            <asp:Parameter Name="OrderID" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="odsPurReqType" runat="server" SelectMethod="QueryDatabase"
        TypeName="DBlookup_tableSP">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
            <asp:Parameter DefaultValue="RtvPurchaseRequestType" Name="Operation" Type="String" />
            <asp:Parameter Name="MAJOR" Type="String" />
            <asp:Parameter Name="MINOR" Type="String" />
            <asp:Parameter Name="DescriptionAr" Type="String" />
            <asp:Parameter Name="DescriptionEn" Type="String" />
            <asp:Parameter Name="OrderID" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>


</asp:Content>

